package DataType;

import java.io.Serializable;

public class MyDataType implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public enum MY_TYPE{MY_STRING,MY_INT,MY_FLOAT,MY_NULL,MY_NUMBERIC };
	
	MY_TYPE type= MY_TYPE.MY_NULL;

	protected String value;
	public static MyDataType getNull()
	{
		return new MyDataType();
	}
	public String toString()
	{
		if(type == MY_TYPE.MY_NULL)
			return "";
		return value;
	}
	public boolean isEqual(MyDataType val) {
		if(val == null || val.getType() == MY_TYPE.MY_NULL)
		{
			return type == MY_TYPE.MY_NULL;
		}
		else
		{
			return type == val.type && ((value == null && val.value==null) || value.equals(val.value));
			
		}
			
		
	}
	public boolean isLessThan(MyDataType val) {
		return type == val.type &&  value.compareTo(val.value)<0;
	}
	public MY_TYPE getType() {
		return type;
	}
	public void setValue(String input){
		if(input == null || input.length() == 0)
		{
			type = MY_TYPE.MY_NULL;
		}
		this.value = input;
	}
	public MyDataType setType(MY_TYPE input){
		MyDataType data;
		String val = value;
		if(input == MY_TYPE.MY_STRING)
			data = new MyString(val);
		else if(input == MY_TYPE.MY_NUMBERIC)
		{			
			
			data = new MyNumberic(val);
		}
		else
		{
			data = new MyDataType();
		}
		return data;
	}
}
